<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Box2D: b2Shape Class Reference</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />

<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  <td id="projectlogo"><img alt="Logo" src="icon.gif"/></td>
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">Box2D
   &#160;<span id="projectnumber">2.2.1</span>
   </div>
   <div id="projectbrief">A 2D Physics Engine for Games</div>
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="hierarchy.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="summary">
<a href="#pub-types">Public Types</a> &#124;
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pub-attribs">Public Attributes</a>  </div>
  <div class="headertitle">
<div class="title">b2Shape Class Reference</div>  </div>
</div>
<div class="contents">
<!-- doxytag: class="b2Shape" -->
<p><code>#include &lt;<a class="el" href="b2_shape_8h_source.html">b2Shape.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for b2Shape:</div>
<div class="dyncontent">
 <div class="center">
  <img src="classb2_shape.png" usemap="#b2Shape_map" alt=""/>
  <map id="b2Shape_map" name="b2Shape_map">
<area href="classb2_chain_shape.html" alt="b2ChainShape" shape="rect" coords="0,56,108,80"/>
<area href="classb2_circle_shape.html" title="A circle shape." alt="b2CircleShape" shape="rect" coords="118,56,226,80"/>
<area href="classb2_edge_shape.html" alt="b2EdgeShape" shape="rect" coords="236,56,344,80"/>
<area href="classb2_polygon_shape.html" alt="b2PolygonShape" shape="rect" coords="354,56,462,80"/>
</map>
 </div></div>

<p><a href="classb2_shape-members.html">List of all members.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="pub-types"></a>
Public Types</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><b>Type</b> { <br/>
&#160;&#160;<b>e_circle</b> =  0, 
<b>e_edge</b> =  1, 
<b>e_polygon</b> =  2, 
<b>e_chain</b> =  3, 
<br/>
&#160;&#160;<b>e_typeCount</b> =  4
<br/>
 }</td></tr>
<tr><td colspan="2"><h2><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a4716243454bb9cf7c7ee1d9cb23ae634"></a><!-- doxytag: member="b2Shape::Clone" ref="a4716243454bb9cf7c7ee1d9cb23ae634" args="(b2BlockAllocator *allocator) const =0" -->
virtual <a class="el" href="classb2_shape.html">b2Shape</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classb2_shape.html#a4716243454bb9cf7c7ee1d9cb23ae634">Clone</a> (<a class="el" href="classb2_block_allocator.html">b2BlockAllocator</a> *allocator) const =0</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Clone the concrete shape using the provided allocator. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">Type&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classb2_shape.html#a3b6093f16c18f8a877519a29674abca0">GetType</a> () const </td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a05a3c445017d96df9238ceefe6ce37ab"></a><!-- doxytag: member="b2Shape::GetChildCount" ref="a05a3c445017d96df9238ceefe6ce37ab" args="() const =0" -->
virtual int32&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classb2_shape.html#a05a3c445017d96df9238ceefe6ce37ab">GetChildCount</a> () const =0</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the number of child primitives. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classb2_shape.html#a6ac968e403e2d93e8ae46d728a2e50fa">TestPoint</a> (const <a class="el" href="structb2_transform.html">b2Transform</a> &amp;xf, const <a class="el" href="structb2_vec2.html">b2Vec2</a> &amp;p) const =0</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classb2_shape.html#aee53a926f4fe64cd03693f6211ef6335">RayCast</a> (<a class="el" href="structb2_ray_cast_output.html">b2RayCastOutput</a> *output, const <a class="el" href="structb2_ray_cast_input.html">b2RayCastInput</a> &amp;input, const <a class="el" href="structb2_transform.html">b2Transform</a> &amp;transform, int32 childIndex) const =0</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classb2_shape.html#a88e9807fab0c8ca9a98d8926e50a1411">ComputeAABB</a> (<a class="el" href="structb2_a_a_b_b.html">b2AABB</a> *aabb, const <a class="el" href="structb2_transform.html">b2Transform</a> &amp;xf, int32 childIndex) const =0</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classb2_shape.html#a61b365526241b47f124789b0309cac69">ComputeMass</a> (<a class="el" href="structb2_mass_data.html">b2MassData</a> *massData, float32 density) const =0</td></tr>
<tr><td colspan="2"><h2><a name="pub-attribs"></a>
Public Attributes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="adb051791133b24f53c6e9a565a7b7bbb"></a><!-- doxytag: member="b2Shape::m_type" ref="adb051791133b24f53c6e9a565a7b7bbb" args="" -->
Type&#160;</td><td class="memItemRight" valign="bottom"><b>m_type</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a5de7a9bd3f9e72ef7025a65c304aaf1a"></a><!-- doxytag: member="b2Shape::m_radius" ref="a5de7a9bd3f9e72ef7025a65c304aaf1a" args="" -->
float32&#160;</td><td class="memItemRight" valign="bottom"><b>m_radius</b></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>A shape is used for collision detection. You can create a shape however you like. Shapes used for simulation in <a class="el" href="classb2_world.html">b2World</a> are created automatically when a <a class="el" href="classb2_fixture.html">b2Fixture</a> is created. Shapes may encapsulate a one or more child shapes. </p>
</div><hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="a88e9807fab0c8ca9a98d8926e50a1411"></a><!-- doxytag: member="b2Shape::ComputeAABB" ref="a88e9807fab0c8ca9a98d8926e50a1411" args="(b2AABB *aabb, const b2Transform &amp;xf, int32 childIndex) const =0" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">virtual void b2Shape::ComputeAABB </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structb2_a_a_b_b.html">b2AABB</a> *&#160;</td>
          <td class="paramname"><em>aabb</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="structb2_transform.html">b2Transform</a> &amp;&#160;</td>
          <td class="paramname"><em>xf</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int32&#160;</td>
          <td class="paramname"><em>childIndex</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td> const<code> [pure virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Given a transform, compute the associated axis aligned bounding box for a child shape. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">aabb</td><td>returns the axis aligned box. </td></tr>
    <tr><td class="paramname">xf</td><td>the world transform of the shape. </td></tr>
    <tr><td class="paramname">childIndex</td><td>the child shape </td></tr>
  </table>
  </dd>
</dl>

<p>Implemented in <a class="el" href="classb2_chain_shape.html#a409c21206e4c84f66700809aac5b164c">b2ChainShape</a>, <a class="el" href="classb2_polygon_shape.html#a00e225b0321bf6bb231a554036ffdf23">b2PolygonShape</a>, <a class="el" href="classb2_edge_shape.html#a30f601c611eb549f9f657eee89d82f9f">b2EdgeShape</a>, and <a class="el" href="classb2_circle_shape.html#aa6889a5af85aa1e272547fd0008eb64a">b2CircleShape</a>.</p>

</div>
</div>
<a class="anchor" id="a61b365526241b47f124789b0309cac69"></a><!-- doxytag: member="b2Shape::ComputeMass" ref="a61b365526241b47f124789b0309cac69" args="(b2MassData *massData, float32 density) const =0" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">virtual void b2Shape::ComputeMass </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structb2_mass_data.html">b2MassData</a> *&#160;</td>
          <td class="paramname"><em>massData</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">float32&#160;</td>
          <td class="paramname"><em>density</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td> const<code> [pure virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Compute the mass properties of this shape using its dimensions and density. The inertia tensor is computed about the local origin. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">massData</td><td>returns the mass data for this shape. </td></tr>
    <tr><td class="paramname">density</td><td>the density in kilograms per meter squared. </td></tr>
  </table>
  </dd>
</dl>

<p>Implemented in <a class="el" href="classb2_chain_shape.html#a009259d589abebeda27fe580d117b11e">b2ChainShape</a>, <a class="el" href="classb2_polygon_shape.html#ad86c4c2a83a7122599462da83bf35389">b2PolygonShape</a>, <a class="el" href="classb2_edge_shape.html#a3a305707a07ca3dffa6f2eaff3735dff">b2EdgeShape</a>, and <a class="el" href="classb2_circle_shape.html#a335edea2ef84789e102dde41ca889828">b2CircleShape</a>.</p>

</div>
</div>
<a class="anchor" id="a3b6093f16c18f8a877519a29674abca0"></a><!-- doxytag: member="b2Shape::GetType" ref="a3b6093f16c18f8a877519a29674abca0" args="() const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">b2Shape::Type b2Shape::GetType </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const<code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Get the type of this shape. You can use this to down cast to the concrete shape. </p>
<dl class="return"><dt><b>Returns:</b></dt><dd>the shape type. </dd></dl>

</div>
</div>
<a class="anchor" id="aee53a926f4fe64cd03693f6211ef6335"></a><!-- doxytag: member="b2Shape::RayCast" ref="aee53a926f4fe64cd03693f6211ef6335" args="(b2RayCastOutput *output, const b2RayCastInput &amp;input, const b2Transform &amp;transform, int32 childIndex) const =0" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">virtual bool b2Shape::RayCast </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structb2_ray_cast_output.html">b2RayCastOutput</a> *&#160;</td>
          <td class="paramname"><em>output</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="structb2_ray_cast_input.html">b2RayCastInput</a> &amp;&#160;</td>
          <td class="paramname"><em>input</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="structb2_transform.html">b2Transform</a> &amp;&#160;</td>
          <td class="paramname"><em>transform</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int32&#160;</td>
          <td class="paramname"><em>childIndex</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td> const<code> [pure virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Cast a ray against a child shape. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">output</td><td>the ray-cast results. </td></tr>
    <tr><td class="paramname">input</td><td>the ray-cast input parameters. </td></tr>
    <tr><td class="paramname">transform</td><td>the transform to be applied to the shape. </td></tr>
    <tr><td class="paramname">childIndex</td><td>the child shape index </td></tr>
  </table>
  </dd>
</dl>

<p>Implemented in <a class="el" href="classb2_chain_shape.html#a85c7a17a15581e0e258c7af561cf5403">b2ChainShape</a>, <a class="el" href="classb2_polygon_shape.html#ac13bded10d09c341f64aaa2750dda6b5">b2PolygonShape</a>, <a class="el" href="classb2_edge_shape.html#aefbae6b3840f486b22ffecee7d0d15fd">b2EdgeShape</a>, and <a class="el" href="classb2_circle_shape.html#a76175079381193917026fdf3702190fa">b2CircleShape</a>.</p>

</div>
</div>
<a class="anchor" id="a6ac968e403e2d93e8ae46d728a2e50fa"></a><!-- doxytag: member="b2Shape::TestPoint" ref="a6ac968e403e2d93e8ae46d728a2e50fa" args="(const b2Transform &amp;xf, const b2Vec2 &amp;p) const =0" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">virtual bool b2Shape::TestPoint </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="structb2_transform.html">b2Transform</a> &amp;&#160;</td>
          <td class="paramname"><em>xf</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="structb2_vec2.html">b2Vec2</a> &amp;&#160;</td>
          <td class="paramname"><em>p</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td> const<code> [pure virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Test a point for containment in this shape. This only works for convex shapes. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">xf</td><td>the shape world transform. </td></tr>
    <tr><td class="paramname">p</td><td>a point in world coordinates. </td></tr>
  </table>
  </dd>
</dl>

<p>Implemented in <a class="el" href="classb2_chain_shape.html#a4fc27b41ecc556985efacf8e0f91c39f">b2ChainShape</a>, <a class="el" href="classb2_polygon_shape.html#a69ccc2f671394b3cc1a00a16ef36b12b">b2PolygonShape</a>, <a class="el" href="classb2_edge_shape.html#a28a977f82e4bc1cf60a3143ba5636c22">b2EdgeShape</a>, and <a class="el" href="classb2_circle_shape.html#a77171941cd1633c337fed1efb366bebb">b2CircleShape</a>.</p>

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="b2_shape_8h_source.html">b2Shape.h</a></li>
</ul>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>



<hr class="footer"/><address class="footer"><small>
Generated on Sat Sep 17 2011 17:35:56 for Box2D by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.5.1
</small></address>

</body>
</html>
